<?php

// 快速测试新权限API
echo "🚀 快速测试新权限管理系统API\n";
echo "=====================================\n\n";

// 测试基本连接
echo "1. 测试基础连接...\n";
$ch = curl_init('http://127.0.0.1:8000/api/admin/permissions/user');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Accept: application/json',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "   请求: GET /api/admin/permissions/user\n";
echo "   状态码: {$httpCode}\n";

if ($httpCode === 401) {
    echo "   ✅ API可达，但需要认证 (401 预期)\n";
} elseif ($httpCode === 404) {
    echo "   ❌ API不可达 (404 错误)\n";
} elseif ($httpCode === 200) {
    echo "   ✅ API正常工作 (200 成功)\n";
} else {
    echo "   ⚠️  意外状态码: {$httpCode}\n";
}

echo "\n2. 测试建议:\n";
echo "   - 如果显示 404，请检查后端服务是否启动\n";
echo "   - 如果显示 401，请先登录获取token\n";
echo "   - 如果显示 200，表示API正常工作\n";

echo "\n3. 手动测试步骤:\n";
echo "   步骤1: 启动后端服务\n";
echo "          php artisan serve --host=127.0.0.1 --port=8000\n";
echo "   步骤2: 启动前端服务\n";
echo "          cd frontend && npm run dev\n";
echo "   步骤3: 浏览器访问\n";
echo "          http://localhost:5173\n";
echo "   步骤4: 访问菜单管理页面\n";
echo "          http://localhost:5173/system/menus\n";

echo "\n🎯 测试完成!\n";
